package weeklyreport

class UserFilters {

	def filters = {
		userOnly(controller:'issue|task|user|admin', action:'|index|show|create|save|edit|update|delete') {
			before = {
				if(controllerName.equals("user") || controllerName.equals("admin")) {
					if(!session?.user?.admin) {
						flash.message = "请以管理员身份登录"
						redirect(controller:"admin", action:"login")
						return false
					}
				} else {
					if(!session?.user?.user) {
						flash.message = "请以用户身份登录"
						redirect(controller:"user", action:"login")
						return false
					}
				}
			}
		}
	}
}
